package com.igeekhome.microservice.feign;

import com.igeekhome.microservice.pojo.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * FeignClient:声明当前接口是一个Feign接口
 * @author yadonghe
 * @date 2020-02-24 13:38
 *
 * fallback:指定某一个类专门用于处理服务提供者调用过程中的异常以及超时等问题
 * 避免每个服务提供者都需要使用@HystrixCommand 并指定回退方法
 */
//@FeignClient(name = "MICROSERVICE-PROVIDER-USER", fallback = UserFeignServiceFallBack.class)
@FeignClient(name = "MICROSERVICE-PROVIDER-USER", fallbackFactory = UserFeignServiceFallBackFactory.class)
public interface UserFeignService {
    //http://MICROSERVICE-PROVIDER-USER/user/get/{id}
    //@PathVariable 之前  如果占位符与参数名一致，value可不写，而此处必须写
    @RequestMapping("/user/get/{id}")
    User get(@PathVariable("id") Long id);

    //@RequestMapping("/user/list")
    //List<User> list();

}
